package cn.xval.ft.app.gen.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.xval.fc.base.response.WrapResponse;
import cn.xval.ft.app.gen.service.FutureAccountService;
import jakarta.annotation.Resource;
import cn.xval.ft.app.gen.params.FutureAccountParams;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.validation.annotation.Validated;
import jakarta.validation.constraints.NotNull;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.PostMapping;
import cn.xval.fc.base.exception.BusinessException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;

@Tag(name="FutureAccount", description="")
@RequestMapping(path = "/account")
@RestController
@WrapResponse
public class FutureAccountController {
    @Resource
    private FutureAccountService futureAccountService;
    @Operation(summary = "添加期货账号")
    @PostMapping("create")
    public FutureAccountParams.FutureAccountInfo create(@RequestBody @Validated @NotNull FutureAccountParams.FutureAccountCreateRequest arg) throws BusinessException {
        return this.futureAccountService.create(arg);
    }
    @Operation(summary = "删除期货交易账号")
    @GetMapping("remove/{id}")
    public void remove(@PathVariable("id") String id) throws BusinessException {
        this.futureAccountService.remove(id);
    }
    @Operation(summary = "修改交易账号信息")
    @PostMapping("modify")
    public FutureAccountParams.FutureAccountInfo modify(@RequestBody @Validated @NotNull FutureAccountParams.FutureAccountModifyRequest arg) throws BusinessException {
        return this.futureAccountService.modify(arg);
    }
    @Operation(summary = "获取交易账号列表")
    @GetMapping("query")
    public List<FutureAccountParams.FutureAccountInfo> list() throws BusinessException {
        return this.futureAccountService.list();
    }
}

